# 测试form表单数据
from fastapi import APIRouter, Form

device_router = APIRouter()


@device_router.post("/add")
async def add_device(device_name: str = Form(), device_type: str = Form(), device_model: str = Form()):
    print(f"device_name: {device_name}, device_type: {device_type}, device_model: {device_model}")
    return {
        "code": 200,
        "message": "请求成功",
        "data": {
            "device_name": device_name,
            "device_type": device_type,
            "device_model": device_model
        }
    }


@device_router.get("/get")
def get_device():
    print("1")
    print("2")
    print("3")
    return {
        "code": 200,
        "message": "请求成功"
    }


@device_router.get("/get_device_by_id/{device_id}")
def get_device_by_id(device_id: int):
    return {
        "code": 200,
        "message": "请求成功",
        "data": {
            "id": device_id
        }
    }
